<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateStatDailyCallTable extends Migration
{
    protected $connection = 'stat';

    public function up(): void
    {
        Schema::create('stat_daily_call', function (Blueprint $table) {
            $table->increments('id');
            $table->date('dt')->comment('统计日期');
            $table->tinyInteger('call_type')->default(-1)->comment('话单类型');
            $table->integer('call_num')->default(0)->comment('总话单');
            $table->integer('success_num')->default(0)->comment('成功话单');
            $table->integer('caller_num')->default(0)->comment('拨打人数');
            $table->integer('receiver_num')->default(0)->comment('接听人数');
            $table->integer('total_call_time')->default(0)->comment('话单总时长');
            $table->integer('call_num_fail')->default(0)->comment('失败话单数');
            $table->integer('call_num_noanswer')->default(0)->comment('无人接听话单数');
            $table->integer('call_num_hangup')->default(0)->comment('主叫挂断');
            $table->integer('call_num_reject')->default(0)->comment('被叫拒绝');
            $table->integer('call_num_err')->default(0)->comment('系统异常挂断');
            $table->timestamps();
            $table->tinyInteger('flag')->default(1)->comment('记录状态');
            $table->index('dt', 'dt');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('stat_daily_call');
    }
}
